package com.examinantsdk.base

import android.util.Base64
import javax.crypto.Cipher
import javax.crypto.spec.SecretKeySpec

open class AESUtils {

    companion object {
        private const val ALGORITHM = "AES"
        private const val TRANSFORMATION = "AES/ECB/PKCS5Padding"
    }

    private val key = "XG7ljE8cX2A4BHWx"
    fun decrypt(cipherText: String): String {
        val cipher = Cipher.getInstance(TRANSFORMATION)
        cipher.init(Cipher.DECRYPT_MODE, SecretKeySpec(key.toByteArray(), ALGORITHM))
        val decodedBytes = Base64.decode(cipherText, Base64.DEFAULT)
        val decryptedBytes = cipher.doFinal(decodedBytes)
        return String(decryptedBytes)
    }

}